Socket
Socket
Sign inDemoInstall

ainojs-finger

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ainojs-finger

Swipe/flick physics for touch devices


Version published
Weekly downloads
5
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

Finger

Swipe/flick physics for touch devices. Usage:

var finger = Finger(element, options)

The element must be a container that contains another slidecontainer. Example markup:

<div class="container">
  <div class="slides">
    <div class="slide"></div>
    <div class="slide"></div>
  </div>
</div>

All CSS must be added manually. Finger implemenets the ainojs-events interface. Example:

// callback for each change:
finger.on('change', function(e) {
  console.log(e.value) // index value from 0-[length]
  console.log(e.position) // position value
  this.inner.style.left = e.position + 'px'
})

// callback for animation complete:
finger.on('complete', function(e) {
  console.log(e.index) // index value from 0-[length]
})

As per 1.2, Finger does not add any requestframe, so you can control it yourself for performance optimizations. The run method calculates the animation and returns a boolean. if the boolean is true, then you can call the run method again in your animation loop. Example:

(function loop() {
  finger.run() && window.requestAnimationFrame(loop)
})

Options:

  • start (0) - starting point
  • duration (600) - animation duration in ms
  • dbltap (true) - set to false for faster tap event if doubletap is not used
  • mouse (true) - enable mouse interactions
  • items (null) - manually set number of items to swipe
  • vertical (false) - enables vertical swipe instead of horizontal

Events:

  • change - triggers if a change has been detected frame. Event object: value and position
  • page - triggers if a page change will happen, before the animation is complete. Event object: index
  • complete - triggers when animation is complete. Event object: index
  • tap - triggers when a tap is detected. Event object: target
  • dbltap - triggers when a doubbletap is detected. Event object: target

FAQs

Package last updated on 05 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc